/*
 *  Copyright 2010 Mahbub Mozadded Sowrov.
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *  under the License.
 */
package com.sowrov.afrigis.tools.timesheet;

import com.sowrov.util.logsystem.ChronicleLogger;
import java.util.ArrayList;
import java.util.Date;

/**
 * Write about the class here
 *
 * @author Mahbub Mozadded (Sowrov)
 * @date Apr 13, 2010
 */
public class PostDataList {

    ArrayList<PostData> list;

    public PostDataList() {
        this.list = new ArrayList<PostData>();
    }

    public void addPostData(PostData pd) {
        this.list.add(pd);
    }

    public void addPostData(int index, PostData pd) {
        if (index >= this.list.size()) {
            this.addPostData(pd);
        } else {
            this.list.add(index, pd);
        }
    }

    public void addPostData(int postLocalId, String projectId, String projectRate, String activityId, String date,
            String description, String strHour, boolean billable) {
        PostData pd = new PostData(postLocalId, projectId, projectRate, activityId, date, description, strHour, billable);
        this.list.add(pd);
    }

    public void addPostData(int postLocalId, int projectIndex, String projectId, String projectRate, int activityIndex,
            String activityId, String date, String description, String strHour, boolean billable) {
        PostData pd = new PostData(postLocalId, projectId, projectRate, activityId, date, description, strHour, billable);
        pd.setProjectIndex(projectIndex);
        pd.setActivityIndex(activityIndex);
        this.list.add(pd);
    }

    public void clear() {
        this.list.clear();
    }

    public PostData getElementAt(int i) {
        if (i >= this.list.size()) {
            return null;
        }
        return this.list.get(i);
    }

    public void removeElementAt(int i) {
        if (i >= this.getSize()) {
            ChronicleLogger.getInstance().logDebug("PostDataList removeElementAt index out of bound");
            return;
        }
        this.list.remove(i);
    }

    public int getSize() {
        return this.list.size();
    }

    public boolean isEmpty() {
        return this.list.isEmpty();
    }
}
